package cn.com.idmy.mq.model;


import cn.com.idmy.mq.coder.MqMsgEncoder;
import cn.com.idmy.mq.model.enums.MqDelayLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class MqMsg {
    protected String topic;
    protected String tag;
    protected String key;
    protected Object body;
    protected MqDelayLevel delayLevel;
    protected MqMsgEncoder encoder;
    protected Object shardingKey;

    public MqMsgEncoder getMsgEncoder(MqMsgEncoder defaultEncoder) {
        return encoder == null ? defaultEncoder : encoder;
    }
}
